#include "../../common/detail.hpp"
#include "../../server/rpc_server.hpp"

void Add(const Json::Value& req, Json::Value& rsp)
{
    int num1 = req["num1"].asInt();
    int num2 = req["num2"].asInt();
    rsp = (num1 + num2);
}

int main()
{
     std::unique_ptr<RPC::server::SDiscribeFactory> desc_factory(new RPC::server::SDiscribeFactory());
    desc_factory->setMethodName("Add");
    desc_factory->setParamsDesc("num1", RPC::server::VType::INTEGRAL);
    desc_factory->setParamsDesc("num2", RPC::server::VType::INTEGRAL);
    desc_factory->setReturnType(RPC::server::VType::INTEGRAL);
    desc_factory->setCallback(Add);

    RPC::server::RpcServer server(RPC::Address("127.0.0.1", 9090), true, RPC::Address("127.0.0.1", 8080));
    server.RegistryMethod(desc_factory->build());
    server.start();
    return 0;
}